package com.pioneer.gui.invoice.view;

import com.pioneer.gui.invoice.view.InvoicePanel;
import com.pioneer.gui.invoice.model.InvoiceModel;
import com.pioneer.gui.invoice.model.DropDownList;
import com.pioneer.gui.invoice.util.Constants;
import com.pioneer.gui.invoice.controller.InvoiceSelection;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import javax.swing.Box;
import javax.swing.BoxLayout;
import java.awt.FlowLayout;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
import javax.swing.JComboBox;
import javax.swing.ComboBoxModel;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JLabel;

import java.util.Vector;

public class FooterPanel
extends JPanel
implements Constants
{
	private final int INVOICE_TERMS_LENGTH=30;
	private final int INVOICE_AMOUNT_LENGTH=6;
	private final int INVOICE_STATUS_LENGTH=9;
	
	private InvoiceModel model;
	
	public JTextField invoiceTerms;
	public JTextField invoiceShipVia;	
	public JTextField invoiceSubTotal;
	public JTextField invoiceDiscount;
	public JTextField invoiceBalance;
	public JTextField invoiceTotal;
	public JTextField invoiceStatus;
	
	//public NavigationPanel navPanel;
	//public DetailsPanel detailsPanel;
	
	public FooterPanel(InvoiceModel model,DetailsPanel detailsPanel)
	{
		this.setLayout(new BorderLayout());
		
		//this.model=panel.model;
		JPanel footerSection=new JPanel(new BorderLayout());		
		
		//JPanel miscInfoPanelWrapper=new JPanel();
		//miscInfoPanelWrapper.setLayout(new GridLayout(2,1));
		
		JPanel miscInfoPanel=new JPanel();
		miscInfoPanel.setLayout(new GridLayout(2,1));
		
		NavigationPanel navPanel=new NavigationPanel(model,detailsPanel);
		
		miscInfoPanel.add(navPanel);
				
		invoiceTerms = new JTextField(INVOICE_TERMS_LENGTH);
		miscInfoPanel.add(new LabelPanel(new JLabel("Terms"),invoiceTerms));
		
		//miscInfoPanelWrapper.add(miscInfoPanel);
		//miscInfoPanelWrapper.add(new Box(BoxLayout.Y_AXIS).createHorizontalStrut(8));
		
		//this.add(miscInfoPanelWrapper);
		footerSection.add(miscInfoPanel,BorderLayout.WEST);
		
		this.add(footerSection,BorderLayout.CENTER);
		
		//JPanel amountsPanelWrapper=new JPanel(new GridLayout(1,2));
		//amountsPanelWrapper.setLayout(new GridLayout(1,2));
		
		//amountsPanelWrapper.add(new Box(BoxLayout.X_AXIS).createVerticalStrut(8));
		
		JPanel amountsPanel=new JPanel();
		
		amountsPanel.setLayout(new GridLayout(4,2));
		amountsPanel.add(new JLabel("Subtotal"));
		invoiceSubTotal = new JTextField(INVOICE_AMOUNT_LENGTH);
		invoiceSubTotal.setHorizontalAlignment(JTextField.RIGHT);
		invoiceSubTotal.setEditable(false);
		amountsPanel.add(invoiceSubTotal);
		amountsPanel.add(new JLabel("Discount"));
		invoiceDiscount = new JTextField(INVOICE_AMOUNT_LENGTH);
		invoiceDiscount.setHorizontalAlignment(JTextField.RIGHT);
		amountsPanel.add(invoiceDiscount);
		amountsPanel.add(new JLabel("Total"));		
		invoiceTotal = new JTextField(INVOICE_AMOUNT_LENGTH);		
		invoiceTotal.setHorizontalAlignment(JTextField.RIGHT);
		invoiceTotal.setEditable(false);
		amountsPanel.add(invoiceTotal);
		amountsPanel.add(new JLabel("Balance"));
		invoiceBalance = new JTextField(INVOICE_AMOUNT_LENGTH);
		invoiceBalance.setHorizontalAlignment(JTextField.RIGHT);
		invoiceBalance.setEditable(false);
		amountsPanel.add(invoiceBalance);
		
		//amountsPanelWrapper.add(amountsPanel);
		
		//this.add(amountsPanelWrapper,BorderLayout.EAST);
		this.add(amountsPanel,BorderLayout.EAST);
	}
}

	
